import javax.swing.*;
import javax.swing.table.DefaultTableModel;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;


public class NameInput extends LabelInput {
	private Named object;
	
	public NameInput(Named object){
		this.object = object;
		setModel(new DefaultTableModel(1,1));
		setValueAt(object.getName(), 0, 0);
		point = object.getLabelPoint();
		init();
        // assume JTable is named "table"
        InputMap inputMap = getInputMap();
        ActionMap actionMap = getActionMap();
        inputMap.remove(KeyStroke.getKeyStroke("ENTER"));


        // DELETE is a String constant that for me was defined as "Delete"
        inputMap.put(KeyStroke.getKeyStroke("ENTER"), "ENTER");
        actionMap.put("ENTER", new AbstractAction() {
            public void actionPerformed(ActionEvent e) {
                System.out.println("hello");

            }

        });
	}
	
	@Override
	protected void write(){
		System.out.println(getValueAt(0,0));
		object.setName((String) getValueAt(0, 0));
		QuiverFrame.getInstance().getActivePanel().repaint();

	}
}
